var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("BehaviorTree"),
    c = e("BevNodeTerminal"),
    l = e("Util"),
    d = e("GameData"),
    u = e("GameModuleView"),
    p = cc._decorator,
    h = p.ccclass,
    f =
        (p.property,
        (function (e) {
            function t() {
                var t = (null !== e && e.apply(this, arguments)) || this;
                return (t.snake = null), (t.vector = null), (t.lately_body = null), t;
            }
            return (
                a(t, e),
                (t.prototype._DoEvaluate = function (e) {
                    (this.snake = e.snake), (this.lately_body = null);
                    var t,
                        o = this.snake.head_pos.x + 50 * this.snake.snake_vector.x,
                        n = this.snake.head_pos.y + 50 * this.snake.snake_vector.y,
                        i = cc.v3(o, n, 0),
                        a = 1e4,
                        r = 150,
                        s = 100,
                        c = d.default.instance.SelfPlayerData.fraction;
                    c < 3e3
                        ? ((r = l.default.randomFrom(60, 150)), (s = l.default.randomFrom(60, 120)))
                        : c < 3e4 && c >= 3e3
                        ? ((r = l.default.randomFrom(130, 200)), (s = l.default.randomFrom(120, 200)))
                        : c >= 3e4 && c < 8e4
                        ? ((r = l.default.randomFrom(230, 350)), (s = l.default.randomFrom(210, 320)))
                        : c >= 8e4 && ((r = l.default.randomFrom(480, 520)), (s = l.default.randomFrom(420, 480)));
                    for (var p = u.default.Insance._layer_snake.snakeList, h = 0; h < p.length; h++) {
                        var f = p[h];
                        if (!f.isDie && f && f.head_pos && f.snakeName != this.snake.snakeName) {
                            var _ = f.head_pos.sub(this.snake.head_pos).mag();
                            _ < this.snake.eatSize / 2 + f.snake_size + r &&
                                _ < a &&
                                ((a = _), (t = f), (this.lately_body = cc.v2(f.head_pos.x, f.head_pos.y)));
                            for (var y = f.snake_body, m = f.snakeUtil.currentDistance, g = 0; g < y.length; g += m) {
                                var v = y[g];
                                if (v) {
                                    var w = i.sub(cc.v3(v.x, v.y, 0)).mag();
                                    w < this.snake.eatSize / 2 + f.snake_size + s &&
                                        w < a &&
                                        ((a = w), (t = f), (this.lately_body = cc.v2(v.x, v.y)));
                                }
                            }
                        }
                    }
                    return null != t;
                }),
                (t.prototype._DoEnter = function () {}),
                (t.prototype._DoExecute = function (e, t) {
                    var o = cc
                        .v2(this.snake.head_pos.x, this.snake.head_pos.y)
                        .sub(cc.v2(this.lately_body.x, this.lately_body.y));
                    return (this.vector = o.normalize()), (t.vector = this.vector), s.BevRunningStatus.k_BRS_Executing;
                }),
                (t.prototype._DoExit = function () {}),
                r([h], t)
            );
        })(c.BevNodeTerminal));
i.default = f;
